import { createWebHistory, createRouter } from 'vue-router';
import Containers from '@/views/containers/index.vue';
const modules = import.meta.glob('./routes/*.js');
const map = {};

const routes = [
  {
    name: 'Home',
    path: '/',
    component: Containers,
    children: [],
    redirect: '/config/note'
  },
];

for (const key in modules) {
  const name = key.replace(/.\/routes\//, '').replace(/.js/, '');
  map[name] = await modules[key]();
  routes[0].children.push(...map[name].default);
}
console.log(routes);

const router = createRouter({
  history: createWebHistory(),
  routes,
});

export default router;
